package itdfq.dfq.Behavior_Patters.Iterator;

/**
 * @Author GocChin
 * @Date 2021/5/15 13:43
 * @Blog: itdfq.com
 * @QQ: 909256107
 * @Descript:
 */
public class PhoneMusic implements Music{
    private  Object[] object = {"大风来--王赫野","后来--刘若英","慢热--满舒克"};
    @Override
    public MusicIterator createIterator() {
        return new SkyMusicIter();
    }
    class SkyMusicIter implements MusicIterator{

        private int currentIndex=0;
        @Override
        public void setmusic(int i) {
            currentIndex=i;
        }

        @Override
        public void next() {
            if (currentIndex<object.length){
                currentIndex++;
            }
        }

        @Override
        public void previous() {
            if (currentIndex>0){
                currentIndex--;
            }
        }

        @Override
        public boolean isLast() {
            return currentIndex== object.length;
        }

        @Override
        public Object currentmusic() {
            return object[currentIndex];
        }

        @Override
        public boolean isFirst() {
            return currentIndex==0;
        }
    }



}

